package Thread;

public class ThreadDemo12 {

    private static int count = 0;

    public static void main(String[] args) throws InterruptedException {

        Object locker1 = new Object();
        Object locker2 = new Object();

        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 5_0000; i++) {
                synchronized(locker1) {
                    count++;
                }
            }
        });

        Thread thread2 = new Thread(() -> {
            for (int i = 0; i < 5_0000; i++) {
                    count++;
            }
        });

        thread1.start();
        thread2.start();

        thread1.join();
        thread2.join();

        System.out.println("count = " + count);
    }
}
